Adds a simple caching scheme to optimize_images

Before optimizing an image, we get the original file's checksum and test whether a file with the checksum as file name exists in the cache. If not, we optimize the image and store it in the cache using the checksum of the original file as the name.

I'm not used to writing python code, so any improvements in style will be much appreciated.
nit: in general in python we try to keep the import order alphabetical.

"from" should go first and then the "import", but keep them ordered.