public void writeBytes(RandomAccessFile raf, int rafIndex, DataConverter dc, MemoryBlock block,
			boolean useBlockBytes) throws IOException, MemoryAccessException {

		if (getSizeOfRawData() == 0) {
			return;
		}

		raf.seek(rafIndex);

		//if ((block.getType() == MemoryBlock.INITIALIZED) || (block.getType() == MemoryBlock.LIVE)) {

		if (useBlockBytes) {
			byte[] blockBytes = new byte[(int) block.getSize()];
			block.getBytes(block.getStart(), blockBytes);
			raf.write(blockBytes);
		}
		else {
			raf.write(toBytes(dc));
		}

		int padLength = getSizeOfRawData() - getVirtualSize();
		if (padLength > 0) {
			raf.write(new byte[padLength]);
		}
		//}
	}
Writes the bytes from this section into the specified random access file.
The bytes will be written starting at the byte position
specified by <code>getPointerToRawData()</code>.

@param raf           the random access file
@param rafIndex      the index into the RAF where the bytes will be written
@param dc            the data converter
@param block         the memory block corresponding to this section
@param useBlockBytes if true, then use the bytes from the memory block, 
                     otherwise use the bytes from this section.
 
@throws IOException if there are errors writing to the file
@throws MemoryAccessException if the byte from the memory block cannot be accesses
Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/SectionHeader.java