Fix TypeError when download fails before temporary filename is constructed

The recent failures in the CI would give a more useful traceback if they weren't raising an exception when the temporary filename is None.