Just a tought: I know we're using ```six``` in other parts of the code, maybe use it here too?

```data = dict([(six.binary_type(k), v) for k, v in data.items()])```

Or maybe be extra explicit and specify the encoding?

```data = dict([(k.encode('ascii'), v) for k, v in data.items()])```

This would pave the way for py3 (am I being a bit too optimistic? :)