Python 3 compatibility update

changed from unicode() to .encode(), compatible in both python 2 and 3. I'm sure there are more python 3 errors, I'll fix them as I work more with this.