Add python 2/3 compatibility for 'range' and unicode strings.