Only utf8 encode type names in Python 2