I've been doing some work with BBC Micro DFS disk images, as used by
BeebEm, lately. In the course of this, I had to write some (rough and ready, but comprehensible) code that can extract files from a disk image and create disk image files,
here on GitHub. While it probably won't be much help in its present form, I released it to the Public Domain, without restrictions; so feel free to borrow any code from it, if it helps you at all.
These BBC Micro disk images contain only the actual data that is readable from the disk; in strict order starting from track 0, with each sector in logical sector order (the physical sector order is created at the time of formatting and can only be changed by re-formatting the disc), then track 1 and so forth. So all the various sync bits, gaps &c. must be generated by the "disk hardware" portion of the emulator. The BBC Micro used an 8271 disk controller, and its disk drives are physically interchangeable with IBM PC drives (though the latter used a twist in the ribbon cable to avoid setting jumpers for each drive's ID; a PC drive will be detected as drive 1/3 by a BBC micro).