Support lazy strings, like from ugettext_lazy

The serializer crashed on lazy strings, like those returned by
ugettext_lazy(). The solution is not very clean, but I could not find a
better solution that works for both Python 2 and Python 3.