Fix for python 3

for Windows Rus (default encoded cp1251):
open(filename, 'w')
filename will be encoded cp1251 for python >= 3