There was a small typo. This works for me: $sBinaryFile = "test.png"
$sStringFile = "testbin.txt"
$sNewBinaryFile = "test_out.png"
; read binary file
$hFile = FileOpen($sBinaryFile, 16)
$bBinary = FileRead($hFile)
FileClose($hFile)
; write hex file
$hFile = FileOpen($sStringFile, 2)
FileWrite($hFile, String($bBinary))
FileClose($hFile)
; --------------------------------------
; read hex file
$hFile = FileOpen($sStringFile)
$sString = FileRead($hFile)
FileClose($hFile)
; write new binary file
$hFile = FileOpen($sNewBinaryFile, 18)
FileWrite($hFile, Binary($sString))
FileClose($hFile)