Fixing 'data should be either a binary or a string'

Sometimes an integer is passed i.e. timeout=30.
Also, text_type won't catch something like to='client:1' etc..
Added check for integer and changed check for string from text_type to string_types