You're doing it pretty much how I would, so if you're getting unusual results it sounds like you're trying to capture the image after calling window.clear() but before window.display(), when the window is in a partially written state. Make sure the window is in a complete state before trying to update a texture from it, or you could potentially use a render texture, by drawing everything you want to capture to that first, once, then using renderTexture.getTexture().copyToImage() to save the file.