Update python3 string handling.

Update FullTextLookupBase.as_sql method to check for strings in a
backwards compatible way.
Remove .encode() from quotes method

In python3, .encode returns a byte string. When this type is passed to
psycopg2.extensions.adapt it casts the value as a ::bytea which causes a
syntax error in the to_tsquery function