modified function about save extracted image