It looks like you left the same condition in above this, and I'm not sure your logic is correct.  I would do this:

~~~python
if isinstance(x, six.binary_type):
    return x
elif isinstance(x, six.text_type):
    return x.encode('utf-8')
else:
    return six.binary_type(x)
~~~