Encode query in cursor.execute if bytes

In python3, from certain libaries (i.e sqlalchemy),
cursor.execute must deal with query in bytes.

So decode the query, before escape the args.