When using jsonify in modules, try several unicode encoding for dumps()

Fixes #4821