cpp: Improve PixelBuffer I/O performance