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

The ticket is at https://code.djangoproject.com/ticket/20977