Use memory stream for frame read and write