An image can not be considered both exported and imported at the same
time, so stop consider it as imported after we consider it exported.
Also add an automatic regression test.
Remove files in /tmp after tests so that other users on the same
machine (like buildbots) also can run make distcheck without getting
"can't overwrite file" errors.