After much searching on google I have finally found a simple yet effective way to convert mkv videos to avi preserving subtitles (and with a little quality loss due to my own needs):
mencoder -oac mp3lame -ovc xvid -xvidencopts pass=1 -sid 0 -zoom -xy 640 -o output.avi input.mkv
Unfortunately it seems like mencoder gets confused when multiple subtitles are showed at the same time; it tries to show them sequentially (thus making them impossible to read) and shows the internal structure of the subtitles (formatting options, position etc.).
During the conversion mencoder shows many errors about subtitles, such as words or lines being too long and osd out of range, which makes me think at some sort of parsing bug.
Is there a way to fix this and have proper subtitles? I am looking for a command line solution because I'm writing a script.