function writeImage() {
    var onFileWriterReceived = function(fileWriter) {
        fileWriter.onwrite = logCallback('FileWriter.write', true);
        fileWriter.onerror = logCallback('FileWriter.write', false);
        fileWriter.write("some text!");
    };

    var onFileTruncateWriterReceived = function(fileWriter) {
        fileWriter.onwrite = logCallback('FileWriter.truncate', true);
        fileWriter.onerror = logCallback('FileWriter.truncate', false);
        fileWriter.truncate(10);
    };

    fileEntry.createWriter(onFileWriterReceived, logCallback('FileEntry.createWriter', false));
    fileEntry.createWriter(onFileTruncateWriterReceived, null);
}
Write image to library using a NATIVE_URI destination type
This calls FileEntry.createWriter, FileWriter.write, and FileWriter.truncate.