Add support for image optimization. Closes #3