Fix generating tests with Python 3.4 on windows

I got an error trying to build on windows with python 3 installed. I think this is caused by a combination of difference in how python 2/3  handles unicode files and python not generating a sane default encoding on windows. This patch should be backwards compatible with python 2.