Scary stuff. We had an impersonator pulling people over for traffic violations and then giving them a piece of his mind. Thankfully that's all he was doing. With the popularity of used police cars on the rise, this is a real concern. Police-like car does not a Police man make.
If it's dark and you are getting pulled, use common sense. If you don't feel safe, put your 4-way flashers on to let the potential cop know you see him, then safely drive to a populated area. You can also call 911 and tell them you think you're being stopped but you're moving to a safe area. It's always good to ask for the ID of the person at your window, too. Politely, mind you.
Also, check your local and state laws on the required uniform for law enforcement on duty. If your local sheriff and chief of police both agree that full uniform is required, then a man in jeans and a t-shirt should raise a huge red flag (this is how the aforementioned impersonator got caught).
Oh and obeying traffic laws is always a good idea. If you're cruising down the highway at 15 over, then you're expecting to be pulled. That gives the other guy an advantage right off the bat.
All of these things will help you avoid the OP's scenario, and THAT is true self defense. If you still find yourself in that situation, then God help you.