Can we define img as a typed memoryview? Access will be much faster here.