import codecs
with codecs.open(filename, 'r', encoding='utf8') as f:
    text = f.read()
with codecs.open(filename, 'w', encoding='utf8') as f:
    f.write(text)
Python reading from a file and saving to utf-8