I believe u need to change with open('screenshot.jpg', 'w') as file_: to with open('screenshot.jpg', 'wb') as file_: to write binary data thanks a lot it helped me tremendously