Optimization of real-space renormalization-group transformations