Converting varbinary to base64 for perspective image component

I've followed some other forum posts for converting a png stored as a varbinary in a sql server database to a base64 string that can be used by the image component, but the component won't read the image. I believe it has something to do with my script converting the value from a scalar back to an array after my transform. Any ideas why "value" in the transform is not returning the same scalar value from the named query? Thanks!