anchor: ImageData:encode
  Encodes the ImageData and optionally writes it to the save directory.
  filedata = ImageData:encode( format, filename )
  format ImageFormat The format to encode the image as.
  filename (nil) string The filename to write the file to. If nil, no file will be written but the FileData will still be returned.
  filedata FileData The encoded image as a new FileData object.
  ImageData:encode( outFile )
  outFile string Name of a file to write encoded data to. The format will be automatically deduced from the file extension.
  ImageData:encode( outFile, format )
  outFile string Name of a file to write encoded data to.
  format ImageFormat The format to encode the image in.