Issue in converting the Pixels values to image

I answered in the above, I used the same python code , read txt file and then get on result.png from python code then opened this image by image photo viewer on my PC.