Add a step in the main loop that renames the jpeg image after compression. This is so that if a webserver is grabbing the image, it can be directed to the renamed one so that there is a smaller chance that it will load the image file while it is being written.