fixed unicode handling across py2 and py3