encode userdata properly