I have made a script which makes a valid ppm file which when opened using a ppm viewer is working properly.
But I don't want my users to install a ppm viewer to view their output images instead I want it to be converted to a global file format like a JPG/JPEG or PNG.