Replace os.rename with shutil.move

Currently the code crashes with `[Errno 18] Invalid cross-device link` and this fixes it, as mentioned in many places online.