[#8] Improve non-ascii support

Most of these changes are for python2 compatability.