The Image and Buffer nodes do this for you. Just create an input in your custom node and connect them.