added the optional paramerer $encode to setKey(), setStartKey() and setEndKey()