I found the problem. In the image there was a flag set to read from bottom-to-top instead of top-to-bottom and another left to right flag was wrongly set