rdopt.c: Refactor common code for lossless / lossy.
rdopt.c: Refactor common code for lossless / lossy.

Ensured that output remains exactly same before/after, with and without
--lossless=1.

BUG=aomedia:442

Change-Id: I82c6e12c10caae02fcdad413c04d75e1c4771610

GrokImageCompression/aom,GrokImageCompression/aom,GrokImageCompression/aom,GrokImageCompression/aom,GrokImageCompression/aom,GrokImageCompression/aom