migration: move buffered_file.c code into migration.c