Begin to add frame writing to ptw_file_write

Begin to write the logic which allows ptw_file_write to write frames.  At the
moment it's very broken, because the function is only passed one frame, but it
acts as though it's been passed many, so it just writes the same frame over and
over again.