Python 3 compatibility

Needed an `.encode()` modifier to get this working on py34.  I added a simple unit test just to show it not breaking on both versions of Python.