contrib: make linearize-data.py cope with out-of-order blocks

Makes it possible to read blocks in any order. This will be required after headers-first (#4468), so should be merged before that.

- For in-order blocks: copy block contents directly. Write prior out-of-order blocks if this connects a consecutive span.
- For out-of-order blocks, store extents of block data for later retrieval. Also cache out-of-order block data in memory up to 100MB (configurable).