Encode str to bytes before passing to unhexlify().

This should fix tests for Python 3.2.