I tried different RC configurations to vary the the frequency,
The penalty in using a low pass filter to smooth PWM is that the response time of changes in PWM value to actual voltage value is going to be slow. The better the filter is at smoothing the voltage the slower it allows that voltage to change.
One way around this is to make the difference between the PWM frequency and the frequency you want to change the voltage at bigger. Which is why dc42 advised you to increase the PWM frequency. That means for any given filter the voltage will be smoother. However your problem seems to be you want to change the voltage quickly.
However, I only get an accurate reading with pulses of 20 ms or greater
and you want:-
during the 2 ms pulse
That means the break frequency of your filter needs to be 10 times higher than it is now. And in order to maintain the same sort of smoothing the PWM frequency needs also to be at least 10 times higher than it is now.