Python 3 support

Changed to python library to work both on Python 2 and Python 3 using the six library.
@eevee In Python3 not explicitly encoding it will cause it use the return value of __str__ which will cause it to return b'value'