Error in downloading png file using regular expression in python

I am trying to download some png format file from a website using regular expression.
Here is my code.In my code i try to create a directory and then inside this,download a png format file and write some information in a text file.
Everything working well.But when i try to open this file it showing an error.

Why it’s happening and how can i fix that? :frowning: