I tend to approach writing characters in the same way that I approach acting a character. As I write, in my mind, I go through the same exercises I do when acting. So, just as I can play someone from a different background than I, I can write them because I am playing the character as I write. This might not be the most efficient way of writing, but its how my mind works.