I have written a program in Python which draws parts of the Mandelbrot set using pygame. However, when I leave it running to generate for a long time and then save the file I get this error: 

pygame.error: SavePNG: could not open for writing 

I'm not sure why this would happen and saving works fine usually. Perhaps when the computer goes to sleep something stops working? But more importantly does anyone know how to fix this?
Are you on windows or on mac? If you're on windows look if you wrote the location like this
"\folder\thing.png", that's an error because you put the starting "\". Remove that and try again.
pygame.error: SavePNG: could not open for writing?