call encode() before hashing

part of issue #40

Python 3 requires encode() to be called on string objects before using hashlib
on them. This change does this, using the 'encoding' instance variable as the
selected encoding.

Note this could be the wrong thing to do but will probably work in most cases.
There might be some encoding out there that throws off the hashing, probably
resulting in a bunch of cache misses and a performance degradation.