Initial Py3 compatibility

Should work just fine in Py2. There are still some byte/string issues, but they don't seem to cause major problems.