If I understand correctly that the results of this script are not being processed by MODx, all you’ll need to do is add this after your getChunk call:
<?php
/* get the max iterations tags are processed before processing is terminated */
$maxIterations= (integer) $modx->getOption('parser_max_iterations', null, 10);
/* parse all cacheable tags first */
$modx->getParser()->processElementTags('', $data, false, false, '[[', ']]', array(), $maxIterations);
/* parse all non-cacheable and remove unprocessed tags */
$modx->getParser()->processElementTags('', $data, true, true, '[[', ']]', array(), $maxIterations);
?>
However, if the script is a Snippet being executed on a Resource, it should get processed automatically before being returned as a MODx Resource.