Added encoding before hashing string (python 3 compatibility).