Added comments and image write to the program