Correctly encode userdata if running in the browser