Added Python 3 support.

More or less, the only changes that were required were to do with
unicode vs ascii strings, so where needed, I have added encodings and b
prefixes on strings. Fixes #1.