BUG: now the code runs in both py2k and py3k has to add encode('utf-8') for the str in f.write()