public static void saveImage(BufferedImage img)
	{
		try
		{
			int val = fileChooser.showSaveDialog(CS355Frame.inst());
			
			if (val == JFileChooser.APPROVE_OPTION)
			{
				File file = fileChooser.getSelectedFile();
				int dot = file.getName().lastIndexOf('.');
				String suffix = file.getName().substring(dot + 1);
				ImageWriter writer = javax.imageio.ImageIO.getImageWritersBySuffix(suffix).next();
				ImageOutputStream out = javax.imageio.ImageIO.createImageOutputStream(file);
				writer.setOutput(out);
				writer.write(img);
				out.close();
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}