imagex_export(): Fix memory leak on error path