measure number of bytes needed