Move save_buffer method to utils module