Fix serialization of non-ASCII messages.

When using `ensure_ascii=False`, the `json` module from Python standard
library returns a text type (`unicode` on Python 2), while `ujson`
returns a UTF8-encoded byte string (`str` on Python 2). This has caused
serialization failure of messages with non-ASCII characters when using
`ujson`. This patch handles the potential difference between
serialization backend outputs and adds appropriate test cases.
Merge pull request #297 from msiedlarek/json-encoding

Fix serialization of non-ASCII messages.