time_elapsed optimized
Writing image to .png file is added