Fix hashlib/unicode issues in Python 3