fixed compression when the width of an image does not fit to byte boundary
fix typo and remove unused variable