Make sure you have the latest version of img2pdf.
Versions before 0.2.4 only run on Python 3, whereas QGIS 2.x uses Python 2.7.
If you still have the issue after verifying/updating, please update your question and show us the code of how you call the .exe from within QGIS.
Update after question clarification:
The error message you receive (and the location of it) very clearly means that you are using python 3.x code with a python 2.7 environment. I would still guess that it's most likely a problem with img2pdf relying on python 3.x code when it shouldn't. Try and raise an issue on their Github about this. When you run in from cmd, you run Python 3.x (which you probably have installed separately?).
It could also mean your system environment variables are shot, because you have two Python installations that might or might not have overriden the same settings (meaning some 2.x code tries loading 3.x code and vice versa).
I can't pinpoint the issue with that little error message, but I'm very sure that's the direction you need to look in.