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.
float_data is a repeated field.  It doesn't have ```has_```.

```
size_in_datum = std::max<int>(datum.data().size(), datum.float_data_size());
```
Since this code path only executes when datum.data().size() == 0, size_in_datum == datum.float_data_size().  But I'll add a sanity check to make sure that's true.