fixed incorrect calculation of required zero padding