Convert lossless m4a to flac
You can convert an m4a file to flac with the ffmpeg command-line tool:
To install ffmpeg:
sudo apt-get install ffmpeg
To convert:
ffmpeg -i filein.m4a -f flac fileout.flac
sudo aptitude install libav-tools
for file in *.m4a; do avconv -i "$file" -f flac "`basename "$file" .m4a`.flac"; done
While both the answers involving ffmpeg/avconv (which I think are essentially the same tool) both work, they currently have a flaw. Namely that lossless m4a is often 24 bit sample, and currently ffmpeg/avconv will generally force the conversion to end up in 16 bit sample.
I believe using sndfile-convert (libsndfile) does not have this problem. Likewise, I believe it can be avoided by using mplayer to decode the m4a before encoding it with ffmpeg or flac. I think soundKonverter on KDE may do this for you.
In any case, whatever you do, I suggest checking whether the original and the converted file have the same bit depth of samples.