Fix typo
Fix encoding but with python2.x

In python2.x we only encode to utf-8 if
we're giving a unicode type.  For a str type,
we assume it's a byte string.