This will preserve the metadata, but the way that M4A stores cover images is fundamentally different from the way that FLAC (and most other audio formats) do it. Unfortunately, FFmpeg is currently unable to handle this. Fortunately, you can extract the cover as a jpeg image on the same step as transcoding the audio, and then use another command-line tool (AtomicParsley) to merge the cover into the M4A.