convert data to bytes for py3