fixed read function

Now it works also when pixels are written not in the right "grid"
format.