I really love writing dialogue scenes, and something that always helps me is acting out the dialogue before I write it. My favorite way to do this is when I am driving (alone, preferably!). Sometimes I will go for a drive and act out the scene I want to write, going over and over it until it is right. Then I will pull over in a safe place and make a note on my phone with how the conversation went. When I write it down, it usually changes some, but this really helps me get to the point of the dialogue.
Also, I agree with knowing your characters well, like in and out, which can only come from writing them more. I write a lot of world building or background short stories with all my characters and I have really found that helps me give them a good voice.