Altered query() to support more data types. Fixes: #2825.

Added support for ByteArrays in query().
Updated documentation for query() to reflect the changes.
Added is_bytearray().