I am having troubles showing images using matplotlip.pyplot.imshow() in a loop. The program randomly stops running with the message: "Process finished with exit code -1