cleaner string/bytes solution, closes #4759

Thanks @takluyver for the suggestion. I'll eventually learn this
strings/bytes/unicode stuff properly for Python3.