Surround readPixelData with an open stream