Windows Support

I tried to use your script on windows and got some errors. This commits fixes this errors on my windows machine. It may be useful to other users too. I did not try these commits other than windows sorry about that.