fix 'decoding Unicode is not supported' eårror

fix p2 bug http://manage.dimagi.com/default.asp?124545#703676
should use `isinstance(v, unicode)` rather than `type(v) is unicode`