generate.py: Fix python3 unicode problem on Windows

generate.py: Fix python3 unicode problem on Windows.
The old way works with python2 on Windows and python2/3 on Linux.