Fix mem read/write functions
they did not return successfully read blocks, instead they always returned the number of read bytes...