serialize typed arrays properly