Move image saving to static function