Fixed #20977 -- Fixed writing migrations to disk on Python 3