Thank you @Arihant25, re-integrating the changes from your PR because
Gabriel is not here to do his fix.
The plan was to get rid of the temporary file altogether and pass a
file-like object, but in the meantime let's at least have something that
works.