@Jose
I have something you could use that I used to solve machine independent, extensible binary storage some time ago that I called 'xsf' for extensible storage format. However, it is C++ based.
The very root is the idea of endian aware XSFStreamIn and StreamOut classes that provide protected methods for block reading and writing varying length data items endian safe. A file header comprised of only byte values contains some basic information about the endian nature of the file (by default the signature of the machine creating the file but you can override this), the expected data alignment and some other properties.
On top of this, there is an XSFStorable class which is able to access the IO methods of the above streams. It defines a basic wrapper for an object you want to be able to store and you get the properties by inheriting XSFStorable in your target class. What this class is, is entirely up to you, it can be all kinds of data. You just use the XSFStorable methods to define how it is serialized and unserialized, which in turn use the block IO routines. The serialized XSFStorable object becomes a well defined chunk within the file, complete with the XSFStorable header information that the system uses when parsing files.
The basic file structure and XSFStorable itself provides some basic type information that allows the system to parse serialized XSFStorable chunks it doesn't recognise (at the very least you can skip past them).
Lastly, the amigaos version's IO routines are realised using asynchronous double buffered routines similar to asyncio.library (in fact based on some old example stuff that I think became the basis of said library too) but also providing on the fly endian conversion for block reads and writes (byteswapping copy, if you prefer) where needed. Naturally those bits use asm ;-)
If you are interested I can send you the code, but as it is part of a larger system, you'll need to pull out the bits you need.