A rate distortion approach to goal-oriented communication