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 == "RGB888"):
		imagepixels = rgb888_to_rgb(bytesequence)
	elif (pixelformat == "GRAYSCALE"): #Black and white yuv422
		imagepixels = blackAndWhite_to_rgb(bytesequence)
	elif (pixelformat == "BAYER"): #Black and white raw
		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)
	g_pil_image = generate_img(outputfile, (0, 0, 0), (xres, yres))
	x = 0
	y = 0
	for i in range(int(len(imagepixels) / 3)):
		color_r = imagepixels[i * 3 + 0]
		color_g = imagepixels[i * 3 + 1]
		color_b = imagepixels[i * 3 + 2]
		g_pil_image.putpixel( (x, y), (color_r, color_g, color_b, 255))
		x = x + 1
		if x > (xres - 1):
			x = 0
			y = y + 1
			if y > (yres - 1):
				break
	g_pil_image.save(outputfile)