imghdr.what
takes the optional second argument. If that is specified the first argument is ignored and the second argument is assumed to contain image bytes.
So you can change the following line:
print imghdr.what(image_file.getvalue())
with:
print imghdr.what(None, image_file.getvalue())