Display Buffer not clearing properly

Hi,

I have a display which updates and displays everything fine, added to this i have a class which reads the buffer everytime the display method is run, this buffer is then written into a tga method. Again this all works fine, except for when;
a) the screen saver kicks in
b) i go to a different desktop while its running
in these two cases the tga files write the buffer as usual but the buffer isnt cleared of the previous screens data so i get two screen shots effectively on one tga, then next frame 2 then 3 etc etc, when i return to the correct desktop everything begins to occur correctly again. Why is the buffer not clearing properly when i dont have it on screen? any ideas?
im running linux and glfw.

Cheers Neil W