In this paper, we propose to embed messages in raw images using a recursive block partitioning technique adopted from HEVC video coding technology. This work introduces a quad-tree partitioning solution in which square blocks of pixels are partitioned recursively according to a homogeneity criterion. As such, large block sizes are allocated for homogenous areas of the image and smaller block sizes are used elsewhere. For this to work, the variable block sizes should cover the whole image without gaps. Additionally, the criterion used for determining the block partitioning should work for both message embedding and message extraction. As such, the extractor process can reproduce the same variable block sizes. Matrix encoding is used for message embedding and extraction, as such, a maximum of one pixel value is changed per block. The proposed solution is assessed in terms of percentage of changed pixels, PSNR, SSIM, histogram changes and blind steganalysis. Comparison with existing work reveals that the proposed solution reduces both the image distortions and pixel change rates. With embedding rates ranging from 2.5% to 38%, the average PSNR of the cover images ranged from 72dB to 60dB, and the average normalized histogram differences ranged from 3 to 12 pixels. It is also shown that the proposed solution is less detectible when tested with blind steganalysis in comparison to existing solutions where the average detection accuracy is 49.8%.