Fix to encode unicode strings