Converting Base64 to Images (solved)

Hi guys, I am trying to convert base64 to files using the code below. It works fine from powershell console, but I am launching this from an external program and it fails here with the error below.

Exception calling "Save" with "2" argument(s): "A generic error occurred in GDI+."
At \\server\path\filename.ps1:151 char:2
+     $Image.Save($outFile,$SRC_FileType)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ExternalException

Edit: Was stupid permissions error on location that I was saving to… My bad…