Fix UnicodeEncodeError in python 2