def put_pixels(image, pixel_values, zigzag=0):
	"""Return an Image after writing pixel values

	Keyword arguments:
	image -- PIL Image object to write into
	pixel_values -- pixel values to be written
	zigzag -- flag to identify if the pixels were flattened in zigzag mannner"""

	if zigzag == 1:
		pixels_itr = image.width
		while pixels_itr < len(pixel_values):
			pixel_values[pixels_itr : pixels_itr + image.width] \
			= (pixel_values[pixels_itr : pixels_itr + image.width][::-1])
			pixels_itr = pixels_itr + 2 * image.width
	image.putdata(pixel_values)
	return image