Makes to_utf8() compatible with Python 3