memdb: added adapted memdb.go file from leveldb-go and our own compaction routines and serialisation