Fix colour code generation in Python 3.

hashlib() needs to be passed an encoded string in Python 3.
Fixes #439. Thanks to Jaroslav Semančík for reporting.