Image saving refactor