avi: Fix file writing

Hi Randy - you mentioned movie writing wasn't working for you.  This
commit fixes it (at least on my linux box).