Unicode fixes for python 2.x

These changes have been tested with Python 3.2.3 and Python 2.7.5.