Encode unicode values before passing through to hashlib

A file with a path containing accented characters caused the `hashlib.sha1()` call to fail as it doesn't expect unicode data. This change encodes the generated string into UTF-8 before it gets passed through.