leveldb/lmdb refactoring

This refactoring places leveldb and lmdb access behind a common interface.  The interface supports:
* open
* close
* put
* sequential scan

It would be nice to use this interface to implement an even simpler database where binary blobs are written sequentially to file and then mmapped in during training.  It's not clear why leveldb and lmdb are used when all that's being done is a sequential scan and I'd like to have timing measurements to learn what is best.

~~There are also a few bug fixes scattered throughout this pull request.  io.hpp allocates too little memory for a strcpy, there's a delete/delete[] mismatch, opencv 3.0 alpha doesn't work as-is, and more.~~ See #1261.

Existing tests pass, but none of the tools are tested as far as I can tell.  This patch might also break any special leveldb or lmdb configurations.  There wasn't an explanation as to why some flags were chosen, so I copied and pasted flags blindly.
I would add `CHECK(datum.float_data())`