There is a script 2to3 that converts Python 2 code to Python 3 code, in addition to the tools mentioned by @FrédéricC. Try running that on the file. (It is intended for .py files, but it may also work on a .sage file. Or you can do sage --preparse file.sage to produce file.sage.py, and then run 2to3 on that.)