Image compression and optimization