Use shutil instead of os.rename because it fails in clusters with different filsystems