add size functions and serializing to OutputStream and byte[]