def METHOD_NAME(bytesequence, outputfile, xres, yres, pixelformat):
	image = []
	if (pixelformat == "YUV422"):
		imagepixels = yuv422_to_rgb(bytesequence)
	elif (pixelformat == "RGB555"):
		imagepixels = rgb555_to_rgb(bytesequence)
	elif (pixelformat == "RGB565"):
		imagepixels = rgb565_to_rgb(bytesequence)
	elif (pixelformat == "GRAYSCALE"): #Black and white yuv422
		imagepixels = blackAndWhite_to_rgb(bytesequence)
	offset = 0
	for i in range(yres):
		line = []
		offset = (xres * 3) * i
		for j in range(xres * 3):
			line.append(imagepixels[j + offset])
		image.append(line)
	print("Output image to file xres {}, yres {}".format(xres,yres), flush=True)
	f = open(outputfile, 'wb')      # binary mode is important
	w = png.Writer(xres, yres, greyscale=False)
	w.write(f, image)
	f.close()
	show_image(outputfile)