corected a few bugs for the query process and JSON encoding of ndb.Key