Writing a numpy matrix to a text file : I am trying to write a numpy array to a text file. But it deos not work. My problem follows.

I am trying to get the RGB pixel values of a picture using `matplotlib.image` and save the values obtained from my program to some file for future use. 

The values are returned in the form of an array, which I tried to write to a text file using the following code. But the file does not open. Nor does it show an error message. 

    import matplotlib.pyplot as plt
    import matplotlib.image as mpimg
    import numpy as np

    img=mpimg.imread('kitten5.jpeg')
    print(img)

    f=open('kitten.dat','w')
    f.write(img)
    f.close()

    imgplot=plt.imshow(img)
    plt.show()

Can someone help? It is not mandatory that the data has to be saved to a text file alone. Other suggestions are equally welcome. 