Good image quality and high hiding capacity are two basic requirements of information hiding systems. Technically, it is very challenging to achieve these two factors simultaneously. The purpose of obtaining either high hiding capacity or good image quality are various from application to application. Inspired from the wet paper codes proposed by Fridrich et al., we propose an information hiding scheme for grayscale images. The proposed scheme first uses a secret key to randomly select a subset of pixels from a cover image as dry pixels. Next, the toral automorphism is applied to the cover image to maximize the number of dry pixel pairs. Then, each secret digit in the base-9 numeral system is embedded into one dry pixel pair. The experimental results show that the proposed scheme can achieve good image quality (i.e., PSNR > 46 dB) and flexible hiding capacity. In addition, unauthorized users without knowing the secret key and the secret parameters used for the toral automorphism can not extract the embedded message.