There are other posts on this and some of the advice there is good.
There are many ways to do it, but the main idea is to keep him busy and teach him that home isn't always fun and away isn't always bad. Bring treats out on long rides with you and give them out only when you are AWAY from home, let him stop and munch (not on his cue, though, on yours). When you do get back to the barn, surprise him. Ask him to go past home and go down another trail. Ask him to go toward home and then back away. When he's acting out make him work harder(lateral movements, circles, halting and backing). The ride begins and ends on YOUR cue. Don't always dismount in the same place...mix things up a little so he can't predict your routine. If he refuses to leave, just keep him working and keep his feet moving. When he goes in the direction you want, relax completely and let him go.
I know first hand how frustrating this sort of thing can be(although mine was more barn sour than buddy sour)....so good luck! Going out alone might be a little scary for him, and if it's scary for you he'll know...you need to practice it and let him gain some confidence and trust in you.
A horse is the projection of peoples' views about themselves--strong, powerful, beautiful--and it has the capability of giving us escape from our mundane existance.