Optimized image saving.
Tried to implement threading (failed).