Python 3 fixes in query.

Change-Id: Id542de1851c04d8ec4256cbdfd6edc7194ee05ad