Your code does not attempt to generate any keys at all, it attempts to read in keys that have already been generated somewhere else and stored in a file. These keys are expected to be in a certain precise formats. If they aren't, you receive the errors you have received.
There's no way an image file is going to simultaneously be parseable as an image, an RSA public key, and an RSA private key by chance.
In any event, since you are using low-level crypto you must become educated about cryptography on your own. The low-level APIs you are using are not foolproof black boxes that you can just mercilessly and randomly hack to death until you get something that runs without errors. You also cannot get this education by asking on forums why said hacking produced an error.