Fix for Python 3.x string compatibility

Use unicode strings where appropriate and byte array otherwise