A three-image algorithm is proposed to retrieve the sample's transmission, refraction and dark-field information in hard X-ray grating interferometry. Analytical formulae of the three-image algorithm are theoretically derived and presented, and evaluated by proof-of-principle synchrotron radiation experiments. The results confirm the feasibility of the proposed algorithm. The novelty of the proposed algorithm is that it allows versatile and tunable multimodal X-ray imaging by substantially relaxing the existing limitations on the lateral grating position. Furthermore, this algorithm can also be adapted for samples with negligible refraction, reducing the number of required sample measurements to two. Furthermore, the noise properties of the retrieved images are investigated in terms of the standard deviations. Theoretical models are presented and verified by synchrotron radiation measurements. It is shown that the noise standard deviations exhibit strong dependence on the lateral grating position, especially in the case of refraction and dark-field images. Further noise reduction and dose reduction can thus be possible by optimizing the lateral grating position for a selected region of interest. Those results can serve as general guidelines to optimize the data acquisition scheme for specific applications and problems.