Utility functions for lossy compression