Make sure queries/conditional rendering are closed properly.

* If we do a partial replay of a frame, a query might be left open. We
  track this and make sure we close any that were left open before the next
  replay.
Don't print random data as a string
Actually break out of loop on invalid data. Oops.
Fix typo using non-serialised parameter
Don't fetch TEXTURE_VIEW_MIN_LEVEL for texture buffers
Avoid using glGetTextureImageEXT as it might be buggy for cubemaps