Fix TypeError: Unicode-objects must be encoded before hashing