freerds: fix possible out of bounds coordinates when encoding region during a resize