Clean up encoding for python2/3