Can "good" female characters be written by men?
Can "good" male characters be written by women?
Of course. Male and female aren't opposites, just variations on a theme. We all have the same physiological and psychological ingredients making us up, just in different proportions. There may be subtle difference between the behavior of the average male and the average female -- which are as much due to social conditioning as anything innate -- but there's also a far wider range of variation within either sex, so there's a ton of overlap in the bell curves.
It's a total myth that you can't understand anyone who isn't of the same sex or race or class or nationality or orientation or whatever as yourself. That's only true of people with narrow minds and no imagination or empathy. It's not hard to understand other people if you just
listen to them, and if you have the imagination to look beyond your own narrow perspective and consider how other types of person could see the world. Heck, you can't be much of a writer if you can't do that. If the only perspective you can understand is your own, then all your characters will be clones of you, or else the ones who are different from you will just be caricatures. Putting yourself in other people's mindsets is basic to being able to write characters well.
And, again, the differences in personality within either sex can greatly outweigh the differences between a given man and a given woman. For instance, when I wrote my
X-Men novel, the character whose mindset I had the most difficulty getting into wasn't Jean Grey or Kitty Pryde or Rogue -- it was Wolverine. It was much harder for me to try to put myself into the mindset and worldview of a career killer than that of a heroine who held values close to my own.
But even so, I could find enough aspects of Wolverine's character to empathize with that I was able to get a handle on him. Every person has lots of different aspects within them, so there's always going to be something about them you can relate to, and that's your entry point into their psyche. The rest is just doing the work to extrapolate from that.
So it's nonsense to think that, say, a male writer could effortlessly write about
every other man and yet be unable to understand
any other woman. That's not how it works. There are many, many ways that people differ from each other, and gender difference is one of the more subtle variations.