For debugging purpose I decided to write texture exporting function:
def image_export(self, file_name: str):
im_format = file_name.rsplit('.')[-1]
if im_format in ('jpg',):
iformat = gl.GL_BGR
elif im_format in ('png',):
iformat = gl.GL_BGRA
else:
raise NotImplementedError
with self: # binding texture
# gl.glPixelStorei(gl.GL_PACK_ALIGNMENT, 1)
im = (gl.glGetTexImage(gl.GL_TEXTURE_2D, 0, iformat, gl.GL_FLOAT) * 255).astype('uint8')
im = np.flip(im, axis=0)
cv2.imwrite(file_name, im)
Tested with 500x500 texture and works fine:

But when I try 500x600 thing goes strange:

I have to reshape it to get desired image:
# ...
im = im.reshape((600, 500, 3)) # added line
im = np.flip(im, axis=0)
cv2.imwrite(file_name, im)
Recently I've asked question glTexImage2D data not filled as expected
so I tried gl.glPixelStorei(gl.GL_PACK_ALIGNMENT, 1), but didnt found it effecting anything.
Reshaping doesn't make sense. Without reshaping, I should simply get 90 degree rotated image. What am I not understanding?
ADDITION:
After reading the comment, tried to summarize my understanding. Can you(someone) verify my conclusion?

