add option for lmdb

This is to replace PR https://github.com/BVLC/caffe/pull/386.