Saves an image to file.
The file extension is used to determine to image format. The BMP (.bmp), PNG (.png) and Portable GrayMap (.pgm) formats are supported.