this was the problem data_size computation was only correct for python 2.7 where data are strings.
for python 3 with encoding data are not in six.string_types (bytes) but for 2.7.
I therefore changed this in way that the correct size is computed outside.