Working with ST3

Fixes for python 3 syntax and string to bytes conversion.