[Added] Refactoring and save image to file method