It would be better to do:
```python
if isinstance(value, unicode):
    return value.encode('utf-8')
else:
    return value
```

It currently may work as expected but I find it complicated to understand.

```python
# this:
return value.encode('utf-8')

# does implictly something like:
if isinstance(value, unicode):
    return value.encode('utf-8')
else:
    return value.decode('ascii').encode('utf8')
```
The `else` raises a `UnicodeEncodeError` when you have a non-ascii utf8-string, which you catch then and return the value
This is okay in this situation because you actually have a utf-8 string, but it's hard to understand when you are not that used to the unicode problem :wink: