Python3 compatibility

I was trying to get it to run on python3 on my system and it kept crashing. Most of the problems were [unicode incompatibilities](http://python3porting.com/noconv.html#more-bytes-strings-and-unicode). A few fixes were with [octals](http://python3porting.com/noconv.html#integer-incompatibilities). The last was because [map() doesn't return a list in python3](http://python3porting.com/differences.html#map). 
This turned out to be a lot bigger than what I thought when I started. I sorry haven't had time to test this much or compare my code style with yours. If anything needs work just let me know.