Boris Johnson will write to the EU seeking another Brexit extension if a deal has not been agreed by October 19, according to government papers submitted to a Scottish court.