I think you just have to get inside the character's head and not worry too much about gender--as long as their motivations are realistic, the rest will follow.
A few surface things to bear in mind: if you're a woman writing about a man, don't forget to have him shave once in a while. If you're a man writing about a woman, remember that her feet are eventually gonna kill her in those five-inch spike heels. There are apt to be physical differences--weight to height ratio, upper body strength, and so on. The plumbing is different. Men and women are apt to bitch/gripe about altogether different things when they come home from work...you get the idea. And you can always hand your work off to someone of the opposite sex to get their take on it.