Fix "TypeError: type() argument 1 must be string, not unicode" in Python 2