cudaMemcpyToArray problems copy a rgb image to cuda array

Hello,
Here I encountered a problem when trying to cpy a image stored in im_data (rgbrgb…) to a 2D cuda array.

Here is the code

cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc();

CUDA_SAFE_CALL(cudaMallocArray(&dA_im, &channelDesc, IM_WIDTH, IM_HEIGHT));
CUDA_SAFE_CALL(cudaMemcpyToArray(dA_im, 0, 0, (void )im_data, 3IM_SIZE, cudaMemcpyHostToDevice));

However, when reading from texture memory, only the first pixel rgb is correct, all other pixels rgb value are messed up.

I also try to declare a cuda array of unsigned char, which works all right. However, I do wish to create the 2D array of each element being a uchar3 (rgb component). Can anybody help me on that?

Thanks !