Image quality option

Rebased patch for issue #8.