Byte/string handling fixes for Python 3.