handle some exceptions while writing during import

A few people get freaky crashes at this point, even though it theoretically
should be impossible (since reading the file succeeded earlier). This should
help the import process not croak at that point.