Implicit decode cause UnicodeDecodeError

Python already works with encoded strings. Thus when calling encode an implicit
decode is called and cause UnicodeDecodeError if non-ASCII chars are used. See
http://docs.python.org/2/howto/unicode.html#the-unicode-type