some improvements to bmp_write_file function (still untested!)