image saving evolved + refactored