Avoid segfault when unloading/deinit image and loading another one