Fix jpeg crash Krita in case of any error
Before this commit, jpeg would crash if the user would try to save
the file into a location with not enough room for this file
or in any other cases that would cause an error.
This commit adds the simple error checking to the exporter, too,
since the importer already had it.
CCBUG:364350