Make QueryResultAggregator py3 compatible
Only check 'long' in python2