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).

Tested: resulting bootstrap.dat (from a node where the chain is out-of-order) can be imported; sha256sum of default range (0..313000):

    08ec49237decea485b246ff7f29e8ec900ffcfef4388a53be92428e800317df6  bootstrap.dat
    21575802677 bytes

Import success:

    2014-10-06 19:05:22 UpdateTip: new best=000000000000000018f6d53196c6f51b402a82e3e5c04164b46efe1f33a1fca8  height=313000  log2_work=79.944961  tx=43442600  date=2014-07-29 11:05:31 progress=0.773505
    2014-10-06 19:05:22 Loaded 313000 blocks from external file in 11534120ms