This is to aid my memory when I come back to this tomorrow. Too late now.
Program segfaults. This is because it goes beyond the end of the image array. This is because it goes beyond the correct number of blocks in y. I do not know why this is, I must have interpreted the file wrong… right?