Move pixel flip from headless test into HeadlessView::readPixels

For easier use downstream.