Added compression before encoding