It doesn't matter what format / codec you use to compress your files, they will lose quality when you compress them, how much you compress them directly relates to how good your final quality is.
DivX is your best bet if you want the best image quality, coupled with MP3 sound, you'll have a great quality file, assuming high bitrate encoding in each audio and video.
Use VirtualDub (best) or NanDub (works with VBR MP3 audio) for encoding .AVI files, use options in those to select your codec (divx) and sound compression codec (MP3)
WMV tends to be buggy, same with ASF, as they are nearly the same. I wouldn't reccomend it.
It all depends on why you want to compress a file.
I can give more detailed info if you want, I do fair bit of resampling / editing of videos. Just email if I forget to check back here.