Pass byte array to the Model rather than string

Use a byte array for the file contents rather than a string so that
checks for binary/compression can be centralised.
Only set custom PublishDir when OutDir is set
Exception messages and stack traces