M-shell X-ray production by C, N and O ions